import request from "@/utils/request";

const ADMIN_URL = "/admin";

const AdminAPI = {
  goodsList(params: GoodsListParams) {
    return request<any, any>({
      url: `${ADMIN_URL}/goods/list`,
      method: "get",
      params,
    });
  },

  orderList(params: OrderListParams) {
    return request<any, any>({
      url: `${ADMIN_URL}/order/list`,
      method: "get",
      params,
    });
  },

  goodsUpdate(data: GoodsUpdateParams) {
    return request<any, any>({
      url: `${ADMIN_URL}/goods/edit`,
      method: "post",
      data,
    });
  },

  goodsCreate(data: GoodsUpdateParams) {
    return request<any, any>({
      url: `${ADMIN_URL}/goods/create`,
      method: "post",
      data,
    });
  },

  goodsDelete(data: GoodsDeleteParams) {
    return request<any, any>({
      url: `${ADMIN_URL}/goods/delete`,
      method: "post",
      data,
    });
  },
};

export default AdminAPI;

export interface GoodsDeleteParams {
  gid: number | string;
}

export interface GoodsListParams {
  page: number | string;
  pageSize: number | string;
}
export interface OrderListParams {
  page: number | string;
  pageSize: number | string;
}
export interface GoodsUpdateParams {
  gid: number | string;
  goods_img: number | string;
  goods_name: number | string;
  goods_price: number | string;
  goods_number: number | string;
}
